package com.hlkj.warboot.module_laboratory.controller;

import com.alibaba.fastjson.JSONObject;
import com.hlkj.warboot.configurer.util.RSAUtil;
import com.hlkj.warboot.configurer.util.RequestUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * OrderPush
 *
 * @Description: 小白外呼订单推送接口
 * @Author: lixing
 * @Date: 2020/10/29 14:36
 */
@Controller
@RequestMapping("OrderPushForXb")
public class OrderPushForXb {
    /*
     * @Description 推送数据
     * @Author lixing
     * @Date 2020/10/29 14:38
     * @Param []
     * @return java.lang.Object
     */
    @RequestMapping("push")
    @ResponseBody
    public Object push(HttpServletRequest request) throws Exception {
        JSONObject outParam = new JSONObject();
        try {
            // 原始参数
            String resultParam = RequestUtil.getRequestParam(request);
            // 私钥解密
            resultParam = RSAUtil.decryptByPrivateKey("MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAIE1ax8y+N9tTriQ3SuhuGP1QGD1bla9ZlcFPB0dylm6YgeJp5bUMqRVaxNJw+2rImsu4Kw8LOUWquZTDywbT5d0BnlO8bLlXhIETXg9laL8YpCI2tQi8EdXQQAkINFjkYt8FiSHi2ynpAlO08p8l6QVCLVi6eIK4ORdTP69gnhBAgMBAAECgYAfFtRcoG4jjHCJlkmxSutMGeHQsp1G/7GVNKw/MUDUEDWwLJ4He61nvynRbUlYcXoJojDrIFuJD8g1PT0EVtnycaHH/E6T2P/McRhN7QX4T36TccJ+UqOL3jMX1hYaBrhdF35QdYj3bgqjGQHTEnqhTpL0/D3Q2IdjJCBwu0KFtQJBAP8ioL8ENrwptByH9M3/weItpzJhQg3ojcBFrKcjzmqpwQlxaO4WS/v9p0h5WzItLnV0Au5ZhUlcUvYu7PoSvAsCQQCBpYdCTUw+ceNSPaGcO1GIv5pR0Q5vdTOQFS/Z0Upj5mGoPiosnYTzPhMhqSdqiETu4avkttpGS4q9BTeDY0BjAkBvXPAJMI+rphBl+7oRSLeaQA8g4G7ynzVwXXk1I13wFNSbiJMiiTz1awxfiAkUZ8BFqDO3Uf/pu5DCwEzUAuVtAkBqswGz5owWZILTH5gPTZ6X7iEiruyzfIDYVyePm7keqO+8mJT7LRTLYE48iMvA2K/q7l4bGQZhjjB7ynxarOfDAkEAvULlpvNs9pEkFjADR1P11g/8Fw7rosoI0tzU3PgN65IvLNYYeYwyVAYEXMevXrDdXMFFA2GeQIVgFz59nI7dEA==", resultParam);
            // 转化成实体对象
            OrderPushBasePojo orderPushBasePojo = JSONObject.parseObject(resultParam,OrderPushBasePojo.class);
            // 校验非空字段
            String checkResult = OrderPushBasePojo.checkNotNull(orderPushBasePojo);
            if (null != checkResult) {
                outParam.put("retCode", "1");
                outParam.put("retMsg", checkResult);
            }
        } catch (Exception e) {
            outParam.put("retCode", "1");
            outParam.put("retMsg", e.getMessage());
        }

        return outParam;
    }


}
